package com.example.campuspass.entity;

import java.time.LocalDate;
import java.util.Objects;

public class Student {
    // 属性（私有化，体现封装性）
    private Long id; // 学生ID（主键）
    private String studentNumber; // 学号
    private String realName; // 真实姓名
    private String className; // 班级名称
    private String phone; // 联系方式
    private LocalDate birthday; // 生日
    private String avatarUrl; // 头像图片的存储路径

    // 构造方法（无参和有参）
    public Student() {
    }

    public Student(String studentNumber, String realName, String className, String phone, LocalDate birthday) {
        this.studentNumber = studentNumber;
        this.realName = realName;
        this.className = className;
        this.phone = phone;
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", studentNumber='" + studentNumber + '\'' +
                ", realName='" + realName + '\'' +
                ", className='" + className + '\'' +
                ", phone='" + phone + '\'' +
                ", birthday=" + birthday +
                ", avatarUrl='" + avatarUrl + '\'' +
                '}';
    }

    // Getter和Setter方法（封装的标准做法）
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getStudentNumber() { return studentNumber; }
    public void setStudentNumber(String studentNumber) { this.studentNumber = studentNumber; }

    // ... 为其他属性生成Getter和Setter
    // 通常IDE（如IntelliJ IDEA）可以自动生成这些方法

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id) && Objects.equals(studentNumber, student.studentNumber) && Objects.equals(realName, student.realName) && Objects.equals(className, student.className) && Objects.equals(phone, student.phone) && Objects.equals(birthday, student.birthday) && Objects.equals(avatarUrl, student.avatarUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, studentNumber, realName, className, phone, birthday, avatarUrl);
    }
}

